<?php

namespace ticket\modules\frontend\models;

use Yii;

/**
 * This is the model class for table "tk_ticket_category".
 *
 * @property int $cid
 * @property int $app_id
 * @property string $category_name
 * @property string $category_descripe
 * @property string $state
 * @property string $create_time
 */
class TicketCategory extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'tk_ticket_category';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['app_id', 'category_name', 'category_descripe', 'create_time'], 'required'],
            [['app_id'], 'integer'],
            [['state'], 'string'],
            [['create_time'], 'safe'],
            [['category_name'], 'string', 'max' => 64],
            [['category_descripe'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'cid' => 'Cid',
            'app_id' => 'App ID',
            'category_name' => 'Category Name',
            'category_descripe' => 'Category Descripe',
            'state' => 'State',
            'create_time' => 'Create Time',
        ];
    }


    public function getTicket()
    {
        $data = $this->hasMany(TicketInfo::className(),['category' => 'cid']);
        return $data;
    }
}
